The Open-source Camera Trap for Organism Presence and Underwater Surveillance (OCTOPUS)

Graphical abstract

The lack of affordable long-term aquatic monitoring systems has limited our understanding of aquatic environments. Non-invasive aquatic ecosystem surveillance provides valuable data essential to our thorough understanding of ecology and biodiversity in marine and freshwater environments. Camera traps have become established in terrestrial systems as a key tool in research, leading to determination of species richness, distribution and abundance [1]. Terrestrial mammals have been estimated to account for 95 % of camera trapping research [2], indicating a severe lack of application in aquatic systems primarily due to the many challenges faced by underwater camera trap systems. Aside from the difficulty of waterand pressure-proofing the electronics, the biggest constraint in aquatic use of camera traps is the attenuation of infrared (IR) light underwater, which is essential to the triggering mechanisms of terrestrial systems. Often easily affordable and attainable action cameras such as GoPro's are placed in waterproof housings and used for underwater visual studies and used as time-lapse camera systems in which a image is captured at regular intervals. However these systems face limitations in battery capacity and often results in partial or missing data since they rely on a timed trigger instead of a motion trigger. Many different vision-based systems have been developed in prior years [3][4][5][6][7], but are often limited by constraints such as deployment duration, photo quality, depth rating, motion sensitivity, etc. The proposed system attempts to address the limitations to these systems while remaining affordable and open-source. While this system cannot attain durations that are possible for terrestrial systems, which can often operate for months without battery recharging, the multi-day operation of this system represents a large improvement for underwater applications over other low-cost underwater camera options. This system uses a motion-trigger function which detects motion using computer vision algorithms implemented by the OpenCV library to capture images of organisms. A motion-trigger system extends battery life and storage capacity by only capturing potentially useful data, instead of running continuously. During data analysis a trigger system further reduces workload by reducing the number of ''empty" photos captured which still require human analysis. This system is controlled using a Raspberry Pi, which in turn runs far-red (FR) and ultraviolet (UV) LED strobes and a camera, three large and easily upgraded battery packs allows this system to run continuously for $72 h durations. Nickel-metal hydride (NiMH) battery chemistry was used for this project, as they were lower in cost and a safer choice when working in wet environments than lithium batteries despite being lower in energy density. An advantage to using a less detectable light frequency to detect motion is similar in purpose to the use of IR in terrestrial camera traps, as it reduces the potential of detectable artificial lighting to influence animal behavior. For example, the consistent periodic white light strobing of a time-lapse system could induce avoidance behaviors in certain animals, thereby biasing observations [8]. The FR strobes are used to illuminate the scene and are invisible to most aquatic organisms, while the UV strobes allow illumination of UV fluorescent tags in tag-recapture studies. However, other color LEDs, such as white, can easily be substituted in the strobes for other applications. The low-cost Schedule 80 PVC housing used for this system can withstand pressures up to 370 psi, allowing deployment depths in excess of 800 ft. This system has a variety of applications within benthic ecology and marine population ecology, as the unique combination of low-cost, multi-day duration, and motion detection enable efficient field work and observations of infrequent organisms to be made unobtrusively. The proposed system is also fairly simplistic, allowing for smaller scientific programs with modest technical resources to construct in-house. To our knowledge, there are currently no commercially available camera systems that are able to meet these specifications. Requirements for the camera system were (1) affordable ($1000USD), (2) motiondetecting and autonomous, (3) long duration deployments ($3 days)), (4) capable of detecting UV florescent markers on organisms for distinguishing individuals, (5) capable of observing organisms during day and night, and (6) be easily constructed using open-source components.

Hardware description and application
Offers an inexpensive platform for observation of benthic organisms Easily customizable due to consumer electronics and open-source distribution, allowing diverse applications Programmable settings Utilizes LED arrays to illuminate the sea floor and capture nocturnal or diurnal species Minimizes observer bias often associated with SCUBA diving

Electronics
This system relies on a Raspberry Pi 3B+ (small single board computer) which controls a variety of low-cost electronics attached to a custom PCB hat (a printed circuit board attached on top of Raspberry Pi 3B+ ) (Fig. 13). The Raspberry Pi 3B+ (RPI) contains an impressive 64-bit quad core processor capable of running wireless LAN and Bluetooth. An extended 40-pin GPIO (noncommitted digital signal pin) header can be used for connection to a custom PCB, while an HDMI connection allows a monitor, keyboard and mouse to be connected, for easy access to the files, code and settings. A 64 GB microSD card holds the operating system and stores all acquired images. The PCB hat houses a Adafruit Pro Trinket microcontroller (3 V version) which operates at 12 MHz (PTM), a Adafruit PCF8523 Real Time Clock integrated circuit (RTC), a INA 219 Voltage and Current Sensor (VCS), a Pololu Electronic power switch (EPS), a 5 V power voltage regulator for powering the RPI, a Adafruit PiOLED -128 Â 32 Monochrome OLED (OLED), and a SparkFun PicoBuck LED Driver (PLD).

Basic system operation
The battery bank is plugged into the PCB and is routed through a fuse and connected to the EPS on the VIN and ground pins. The battery power is also connected directly to the PTM, which is powered at all times when the battery is connected to the PCB. The PTM is connected to the Blue Robotics underwater switch. When the switch is activated, the PTM sends a logic signal to the EPS to provide power to the RPI and PLD. The RPI then boots up and activates the OLED, starting the image acquisition process. The PTM also serves as the strobe channel selector as the strobe output pin from the RPI is separate from the strobe channel pin. The OLED, RTC, and VCS) are all connected to the RPI i2c interface for communication.

Build instructions
Step-by-step instructions to assemble the PCB hat, batteries, wiring and 3d-printed structural components. Refer to parts list (Table 2), design files (Table 1), and visual aids (Figs. 1-55) for necessary components and assembly process.             13. Attach a Female to Female jumper (P20) from I2C bus (P5) to GPIO2 (Pin# 3) and GPIO3 (Pin# 5) on Raspberry Pi 3B+ (P19) (Fig. 15). 14. If the female to female jumper is too long or obstructing board access, a small zip tie can be used to secure the jumper to the top of the real time clock (P15) and/or current sensor (P13) using the attachment points at the top corner of each board. 15. Camera and attached ribbon cable (P22) can be inserted into Raspberry Pi CSI port Fig. 16, following assembly of camera components and removal of IR filter (See sections 5.1.2 and 5.1.3.) 16. To operate the strobe system (assembly instructions in 5.1.4) a wiring harness must be connected to picoBuck LED driver (P10) to allow LED control. Using screw mount terminals (P11), connect 10-12 in. of wire (P25) to each terminal following the colored diagram shown in Fig. 17. Attach wires to tin crimp pins and insert into 6 circuit Molex plug (P24) in accordance with the diagram found in Fig. 18.

PCB assembly instructions
17. After uploading trigger_camera_disk.img (DF10) onto a 64 GB MicroSD card (P51), insert the card into the receptacle at the base of the Raspberry Pi.

Camera FR filter removal
Before the camera components can be used in tandem with an FR illumination system, the factory installed FR filter must be removed, for removal instructions beyond this manual refer to HQ camera filter removal .  1. Begin by cleaning the project area in an effort to minimize any particulates which may fall in the exposed camera sensor during filter removal. 2. Remove the CS-mount adapter attachment ring Fig. 20, followed by the ¼" tripod mount (requiring hex lock keys) which is unnecessary and will be permanently removed (Fig. 21). 3. Remove the two 1.5 mm hex lock keys from the base of the main circuit board and gently lift the lens mount to expose the IR filter (Fig. 21). 4. Using a sharp blade or fine tipped flathead screwdriver, carefully loosen the edges of the filter from the top of the Sony IMX477 sensor and remove the FR filter without breaking it (Fig. 22). 5. Reinstall the lens mount and replace the CS-mount adapter ring before attaching the wide angle lens (P21), refer to Figs. 23, 24.      1. Attach the LED support base (DF4) to the port mount (DF2) and secure with bolts (P28) (Fig. 29).
3. Install the wedge (DF1) used for expanding the port mount by inserting a nut (P26) into the wedge and threading the bolt (P27) through the port mount and into the nut (Figs. 30, 31). 4. Mount LED starboards (P31, P32) onto LED mounting plate (DF5) using screws (P29). 5. Solder wiring onto LED starboard terminals, run wire through port mount and out, to prevent wires from getting pinched during LED port mounting (Fig. 33). Install wire terminals in a female molex connector (P24) (Figs. 33, 34), for later connection to the male molex connector, attached to the strobe system seen in Fig. 19.    1. Battery pack (P33) wires are cut from the original 6 pin plug and mounted in a female 6 pin molex plug (P34) using tin crimp pins (P35) (Fig. 35). Yellow wires are combined into one crimp pin. 2. Threaded rods (P36) are fitted with nuts (P37) in order to mount battery holders in place, along the length of the rods (Fig. 36). After installing all the components along the length of the rods the tightening of the nuts will form a rigid structural design. To efficiently move nuts along the threaded rod a dremel with a soft polishing tip was used to spin nuts quickly along the length of the rods. 3. Two battery holders are mounted back to back (DF7), to support the middle of the battery (Figs. 37, 38). 4. Before installing the final battery mount end cap the wired battery pack is placed inside the battery holders before being fixed in place with the last mount (Figs. 38, 39), two more battery packs are installed in a similar fashion (Fig. 39).  (Figs. 45, 46). The wiring harness clips to the sides of the battery holders (DF6,7) to prevent damage during loading and unloading from the housing. At each wire intersection along the wiring harness heat shrink tubing (P53) was used to maintain a strong waterproof connection. 9. After all components are in place and securely fastened trim off excess threaded rod length using an angle grinder. 10. Battery packs can be charged by wiring a battery charger (P47) to a male molex connector in the same configuration as the wiring harness, to allow individual charging of each battery. Female molex plugs (P34, P35) will be wired to each battery charger.   3. Attach a second t-joint to the 6in pipe segment and insert a 6in pipe into each of the 3 available female receptacles (Fig. 49). 4. Prepare 3 union joints (P43) for attachment by removing the union joint sleeve and replacing it with a plexiglass plate (P44) for the loading and camera ports and a glass plate (P45) for the strobe port (Figs. 50, 51).    5. The plexiglass plate used to cover the loading port requires the installation of a Blue Robotics high pressure switch (P46). Using the appropriate drill bit, make a larger hole ¼" through the plexiglass in the center of the plate. Create a second smaller hole continuing through the plate which will allow a taping set to thread the hole (Fig. 52). 6. Install the Blue Robotics switch by removing the nut and wrapping the threads with plumbers tape. Using a wrench screw the switch into the hole and replace the washer (Figs. 53, 54). 7. The completed housing should match the visualization shown in Fig. 55. 8. After camera and LED assembly install port mounts in designated ports (Fig. 2) Table 3):

Configuration
The main operating parameters are specified in the configuration file ''settings.cfg", which includes general program settings, image acquisition settings, and triggering thresholds. The table below lists all configurable parameters and default values (see Table 4).

General operation
Each power up cycle is considered a ''deployment". The system is powered up by turning the Blue Robotics underwater switch knob (P46) to the ''on" position (see Fig. 54). The system will then boot up the raspberry pi and automatically start the main program script using the command line call ''python3 triggercam_main.py". This program reads the ''setup.cfg" file and stores the settings in a python dictionary to guide the main program execution. The initial action of the program is to display the IP address of the Wi-Fi interface for the raspberry pi, the system voltage and free disk space for 30 s. The program will then count down for the pre-determined number of minutes (as set by the user in the settings) before starting acquisition. Each new deployment is given a name based on the time using the format DMMDDYYYY-Thhmmss. A set of folders is created  for storing images and log files related to each deployment, as well as a copy of the configuration file ''settings.cfg" for reference. The voltage level is recorded in the deployment log file whenever an image is taken, enabling the voltage draw profile to be evaluated.
When conducting field deployments several factors should be accounted for to promote high quality pictures and prevent system failure. O-rings should be covered in a light coat of silicone-based vaccume grease (P49). All surfaces should be cleaned with alcohol and microfiber cloth prior to greasing to prevent contaminants ruining the waterproof seal. After assembling the system O-rings must form an smooth seal against the plexiglass without any visible bubbles or cataminants. Dessicant packets should be loaded with the system to prevent condensation on viewports and aid in maintaining system  integrity. When deploying; systems weigh approximately 13 kg at the surface and are negatively boyant when submerged. This must be accounted for if manually deploying using SCUBA. Sidemounting cameras using boltsnaps proved effective but the use of liftbags would be recommended if more than a few systems are being deployed or housing size is increased to accomodate more batteries. Camera systems can be mounted in a number of orientations, however facing the seafloor proved most effective at limiting uneccesary triggering events and observing benthic species. Camera and LED ports act as boyant portions of the housing and tend to turn the ports upright, thus cameras should be secured to maintain the frame on the desired subject, zipties or bungeechords proved effective for this issue. When collecting camera systems avoid opening housings at dive site to prevent damage during transport, keep seals clean, and to prevent saltwater from entering housing. Before opening housing, dunk entire housing in clean freshwater to rinse off any saltwater, allow the housing to dry before opening for charging, data removal and maintence.

Operation modes
In intervalometer mode, a single still image is taken at specified time intervals using preconfigured image settings and strobe channel up to a specified maximum number of images or until other exit conditions are detected, such as memory limitation for data writing or low voltage. In triggered mode, the camera takes a low resolution image (trigger evaluation image -TEI) using unobtrusive red light strobe or ambient light at specified intervals to evaluate the scene for change, such as the arrival of a target. The triggering process is illustrated graphically in Fig. 56. When sufficient change is detected, a full  resolution image is taken using the desired strobe channel for proper illumination. The TEI sequence is also stored to allow post-deployment evaluation of trigger performance and adjustment of trigger sensitivity.

Triggered operation details
The trigger operation relies on motion detection by using a background subtraction algorithm termed Mixture-of-Gausians (MOG; [9]). With OCTOPUS, a background model is constructed at the start of data collection from a series of TEI images (320 Â 240 monochrome) of the scene background. TEI images can be illuminated using a lower detectability strobe such as red (600-nm) which is less detectable by many marine organisms, or collected with ambient lighting. After the TEI images are captured, a low pass filter is applied (Gaussian Blur) with kernel size 5x5 pixels, and the image is cropped to the boundaries specified in the region-of-interest (ROI) parameter. The low pass filtering eliminates noise and produces a more stable background, and the ROI allows for a focus area for motion detection to be specified, for example, away from the image edges. After the background model is established, each successive frame is evaluated for differences relative to the background (or image ''foreground") based on an initial sensitivity threshold (in OCTOPUS configuration this is fore-ground_threshold parameter). The background model is continually updated as images are collected. Once the foreground  is extracted as a binary mask image, it is subjected to a second level of scrutiny by using one of two approaches; 1) total pixel level -this is simply a count of non-zero pixels in the mask, or 2) by considering object size, where the foreground mask is evaluated using a connected components step, and looking for objects that meet a minimum pixel area. Before applying the connected components step, a dilation and erosion morphological operator is sequentially applied to the foreground mask to merge fragmented foreground objects that are likely a single target. If the total number of foreground pixels exceeds the min_pixel_count (approach 1), or any of the objects in the scene exceed the min_object_size parameter value (approach 2), conditions for a trigger event have been met. Capturing a triggered image consists of resetting camera resolution to the specified desired resolution (image_resolution parameter), and if desired, apply contrast enhancement using the Contrast Limited Adaptive Histogram Equalization (CLAHE) implementation in OpenCV. A secondary strobe channel can be specified for this operation, for example a white, full spectrum, strobe for capturing the true color properties of the target. The full resolution image is then written to disk.  The Raspberry Pi computer is set up to automatically connect to a specified wireless network, if available. This needs to be set up during the initial system build, with a user specified network. To download images collected during a deployment, the system must be powered on within range of the wifi router. Alternatively, the front port can be opened and an ethernet cable used to make a hardwired connection to a router. Then an FTP program such as WinSCP or FileZilla can be used to connect to the Raspberry Pi and transfer the files to another computer. The ''settings.cfg" file can also be accessed at this time by directly editing the file using an SSH client or by copying the file to a separate computer, editing and then replacing it on the Raspberry Pi.

System performance
We tested the performance of this camera system in one of the most challenging situations for an aquatic camera trap: tracking the movements of a highly mobile animal (octopuses) in a high-current location. Four camera systems were built and tested at Rosario Beach Marine Laboratory followed by a series of field deployments at Driftwood Park, in Island County, Washington state to monitor ruby octopuses (Octopus rubescens) at den sites [10]. Driftwood Park is located on Admiralty  Inlet, one of only two inlets to the Puget Sound, Washington, USA, and therefore experiences significant and frequent tidal currents. Cameras were mounted in deployment frames and placed above occupied octopus' dens. In total, 16 deployments were performed which amassed over 785 h of data collection (nearly 33 days). During these deployments the systems were able to record 46 individual octopuses, with 15,972 min (266 h) of octopuses present beneath the cameras in addition to 1,485 instances of other macrofauna species. A total of 249,163 triggered images were captured, which likely represents a relatively high value of triggered images for the deployment time due to the high current nature of the deployment site. This is opposed to 1.4 million images that would have been captured by a 2 s interval time-lapse system that would be need to capture data at a similar temporal resolution as this device. By utilizing the motion activated feature of the camera, octopus were monitored continuously both day and night. The UV strobe system incorporated into the camera was used to distinguish individual octopus by fluorescing subdermal tags, however this function could be easily replaced with a different lighting system adapted to the researchers needs. System settings for these field deployments were configured to utilize auto exposure without auto contrast, an ISO of 800, image quality of 95 and monochrome image depth. The data collected led